package main

import (
	"fmt"
	"time"
)

func main() {
	//now := time.Now()	//当前时间
	//fmt.Println(now)
	//year := now.Year()	//年
	//fmt.Println(year)
	//month := now.Month()
	//fmt.Println(month)
	////时间戳
	//now.Unix()
	////格式化
	//fmt.Println(now.Format("2006-01-02 15:04"))
	lcn, _ := time.LoadLocation("PRC")
	fmt.Println(time.Now().Location())
	c := time.Now().In(lcn)
	fmt.Println(c)
	return

	//两个时间相减
	//获取时区
	loc, err := time.LoadLocation("Asia/Shanghai")
	if err != nil {
		fmt.Println(err)
		return
	}
	//按照指定时区解析字符串时间
	parseTime, err := time.ParseInLocation("2006-01-02 15:04:05", "2021-12-02 12:25:00", loc)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(parseTime)
	subTime := time.Now().Sub(parseTime)
	fmt.Println(subTime)
	fmt.Println(int(subTime.Seconds()))



}
